package sn.gandal.agriculture.agrimobile.j2me.businessObjects;



import java.io.IOException;

/**
 *
 * @author dysow
 */
public class Adresse
{

    private String webAddress;

    public Adresse()
    {
    }

    public Adresse(String address)
    {
	this.webAddress = address;
    }

    /**
     * @return the webAddress
     */
    public String getWebAddress()
    {
	return webAddress;
    }

    /**
     * @param webAddress the webAddress to set
     */
    public void setWebAddress(String webAddress)
    {
	this.webAddress = webAddress;
    }

    /**
     * Sérialize l'Adresse.
     * @return data - byte []
     * @throws java.io.IOException
     */
    public byte[] serialize() throws IOException
    {
	return webAddress.getBytes();
    }

    /**
     * Désérialize l'Adresse.
     * @param serial byte []
     * @throws java.io.IOException
     */
    public void deSerialize(byte[] serial) throws IOException
    {
	webAddress = new String(serial);
    }

    public String validerAdresse()
    {
	String error = "";

	if (!((this.webAddress.startsWith("http://")) || (this.webAddress.startsWith("https://"))))
	{
	    error = "L'adresse n'est pas valide";
	}

	return error;
    }
}
